<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 *
 * An open source application development framework for PHP 4.3.2 or newer
 *
 * @package		CodeIgniter
 * @author		ExpressionEngine Dev Team
 * @copyright	Copyright (c) 2008 - 2009, EllisLab, Inc.
 * @license		http://codeigniter.com/user_guide/license.html
 * @link		http://codeigniter.com
 * @since		Version 1.0
 * @filesource
 */

if ( ! function_exists('email_send')){
	function email_send($from, $to, $subject = 'Test email', $message = 'Hello World'){
		$crlf	= "\n";
		$tmp	= explode('<', $from);
		$tmp[0]	= trim($tmp[0]);
		$tmp[1]	= trim($tmp[1]);
		$tmp	= '=?UTF-8?B?'.base64_encode($tmp[0]).'?='.(empty($tmp[1])?'':' <'.$tmp[1]);
		$headers	= '';
		$headers	.= 'From: '.$tmp.$crlf;
		$headers	.= 'Reply-To: '.$tmp.$crlf;
		$headers	.= 'Return-Path: '.$tmp.$crlf;
		$headers	.= 'Message-ID: <'.time().rand(1000,9999).'@'.'i-see.com'.'>'.$crlf;
		$headers	.= 'X-Mailer: PHP/'.PHP_VERSION.$crlf;
		$headers	.= 'MIME-Version: 1.0'.$crlf;
		$headers	.= 'Content-Type: text/plain; charset=UTF-8'.$crlf;
		$headers	.= 'Content-Transfer-Encoding: 8bit'.$crlf;
		$subject	= '=?UTF-8?B?'.base64_encode($subject).'?=';
		return mail($to, $subject, $message,$headers);
	}
}